package com.tailyou.hms.smartcity.https;

import android.util.Log;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public abstract class HttpCallback<T> implements Callback<HttpResponse<T>> {

    @Override
    public void onResponse(Call<HttpResponse<T>> call, Response<HttpResponse<T>> response) {
        if (response.body() != null && response.body().getData() != null) {
            onSucceed(response.body().getData());

        } else {
            onFailure(call, new Exception("数据为空"));
        }
    }

    protected abstract void onSucceed(T data);

    @Override
    public void onFailure(Call<HttpResponse<T>> call, Throwable throwable) {
        Log.e("HTTP_ERR_MSG", throwable.getMessage());
    }

}
